package com.ruoyi.system.common.utils;

import com.alibaba.fastjson.JSONObject;
import com.weaver.esb.spi.EsbManager;
import com.weaver.esb.spi.EsbService;
import com.weaver.esb.spi.RequestConfig;

public class EsbUtil {

    /**
     * 应用标识
     */
    private static final String APP_KEY = "64caed2d-ab47-4116-b1be-6caec02a2fa1";

    /**
     * 事件标识
     */
    private static final String EVENT_KEY = "createworkflow";

    /**
     * ESB 测试服务所在地址
     */
    private static final String URL = "http://10.2.10.115";

    /**
     * ESB 正式服务所在地址
     */
    private static final String URL_PRO = "http://10.2.10.8";

    private static final String PROTOCOL = "http";

    public static String getService(JSONObject obj) {
        RequestConfig requestConfig = new RequestConfig();
        requestConfig.setAppKey(APP_KEY); //应用标识
        requestConfig.setServerUrl(URL_PRO);//ESB 服务所在地址
        requestConfig.setSign(Boolean.FALSE);    //启用签名
        String params = obj.toString(); //事件请求数据
        EsbService service = EsbManager.getService(PROTOCOL, requestConfig); //获取 ESB 服务
        return service.execute(EVENT_KEY, params);
    }
}
